package com.nwpu.coursesupport.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nwpu.coursesupport.entity.bean.JSONResult;

@Controller
@RequestMapping("/student")
public class StudentController extends AbstractController{
	
	@RequestMapping(value="/update",method=RequestMethod.POST)
	@ResponseBody
	public JSONResult update(@RequestParam("data")String data){
		JSONResult rst=invokeService("student","update",data);
		return rst;
	}
	
	@RequestMapping(value="/changeAvatar",method=RequestMethod.POST)
	@ResponseBody
	public JSONResult changeAvatar(@RequestParam("data")String data){
		JSONResult rst=invokeService("student","update",data);
		return rst;
	}
	
	@RequestMapping(value="/detail",method=RequestMethod.GET)
	@ResponseBody
	public JSONResult detail(){
		int id=(int) getSession().getAttribute("id");//从session中获取该学生id
		String data="{\"id\":\"+"+id+"\"}";
		JSONResult rst=invokeService("student", "detail",data);
		return rst;
	}
	
	@RequestMapping(value="/getDetail",method=RequestMethod.GET)
	@ResponseBody
	public JSONResult detail(@RequestParam("id")int id){
		String data="{\"id\":\"+"+id+"\"}";
		JSONResult rst=invokeService("student", "detail",data);
		return rst;
	}
	@RequestMapping("/ajaxListData")
    @ResponseBody
    public JSONResult ajaxListData(@RequestParam("data") String data) {
        JSONResult result = invokeService("student", "listData", data);
        return result;
    }
	

}
